<%@ page contentType="text/html; charset=utf-8"%>
<%@ include file="/jsp/inc/header.jsp" %>
<c:set var="title" value="文章"/>
<c:set var="rootpath" value="${CONTEXT_PATH}/admin/article/article"/>
<!DOCTYPE html>
<html>
<head>
    <link href="${STATIC_HOST}/css/ligerui.css" rel="stylesheet" type="text/css"/>
    <link href="${STATIC_HOST}/css/common.css" rel="stylesheet" type="text/css" />

    <script src="${STATIC_HOST}/js/jquery/jquery-1.7.2.min.js" type="text/javascript" ></script>    <!--兼容性问题--->
    <script src="${STATIC_HOST}/js/ligerUI/ligerui.min.js" type="text/javascript"></script>
    <script src="${STATIC_HOST}/js/json/json2.js" type="text/javascript"></script>
    <script src="${STATIC_HOST}/js/LG.js" type="text/javascript"></script>
    <script src="${STATIC_HOST}/js/ckeditor/ckeditor.js" type="text/javascript"></script>
    <script src="${STATIC_HOST}/js/article.js" type="text/javascript"></script>
    <script src="${STATIC_HOST}/js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>

    <title>${article.id==0 ? '新增' : '修改'}${title}</title>
</head>
<body>
<form:form commandName="article" class="l-form" id="mainform" name="mainform" method="post" action="${rootpath}/save.do">
<div class="pnl J_LigerForm">
    <div class="pnl-hd">
        <div class="hd-tit"><span>当前位置: 宇宙CMS&gt; <c:if test="${article.id>0}"><a href="${rootpath}/list.do"/>${title}列表</a></c:if>&gt; ${article.id==0 ? '新建' : '更新'}${title}</span></div>
        <div class="hd-bar">
            <input value="xxxxx" type="button" class="l-button" onClick="">
            <input value="xxxxx" type="button" class="l-button" onClick="">
        </div>
    </div>

    <div class="pnl-bd">
    <div id="errorLabelContainer"> <form:errors path="*"/>${error.param.wrong}</div>
    <input type="hidden" name="id" id="id" value="${article.id}"/>
    <!--=============================文章状态==========================-->
    <c:if test="${article.id>0}">
    <fieldset class="field">
        <legend class="toggleBar">文章状态</legend>
        <div class="field-bd">
            <table class="tblWrap">
                <tr>
                    <th>文章ID：</th>
                    <td>${article.id}</td>
                    <th>发布状态：</th>
                    <td>
                        <c:if test="${article.publishStatus==0}">未发布</c:if>
                        <c:if test="${article.publishStatus==1}">已人工发布</c:if>
                        <c:if test="${article.publishStatus==2}">已自动发布</c:if>
                        <c:if test="${article.publishStatus==3}">已撤稿</c:if>
                    </td>
                    <th>发布时间：</th>
                    <td><fmt:formatDate value="${article.publishTime}" pattern="yyyy-MM-dd HH:mm" /></td>
                    <c:if test="${article.modifyUserId >0}">
                        <th>修改人：</th>
                        <td>${modifyUserName}</td>
                    </c:if>
                    <th>修改时间：</th>
                    <td><fmt:formatDate value="${article.modifyTime}" pattern="yyyy-MM-dd HH:mm" /></td>
                </tr>
            </table>
        </div>
    </fieldset>
    </c:if>

    <!--=============================文章标题==========================-->
    <fieldset class="field" id="titleField">
        <legend class="toggleBar">文章标题</legend>
        <div class="field-bd">
            <table class="tblWrap">
                <tr>
                    <th><span class="required">*</span><font style="font-weight:bold;">文章标题：</font></th>
                    <td><input type="text" id="title" maxlength="50" name="title" ligerui="width:300" value="${not empty article.title ? article.title.replaceAll('\"', '&quot;') : '无标题'}" validate="{required:true,minlength:0,maxlength:100}"/></td>
                    <td id="S_titleControl">（设置短标题）</td>
                    <th><span class="required">*</span><font style="font-weight:bold;">信息源：</font></th>
                    <td><input type="text" name="sourceName" id="sourceName" value="${not empty article.sourceName ? article.sourceName.replaceAll('\"', '&quot;') : '俏丽吧'}" ligerui="width:100"/></td>
                </tr>
                <tr id="S_title" style="display:none">
                    <th><span class="required"></span>短标题：</th>
                    <td>
                        <input type="text" name="titleShort" id="titleShort" value="${article.titleShort}" ligerui="width:300"/>
                    </td>
                </tr>
                <tr>
                    <th><span class="required"></span>关键词：</th>
                    <td>
                        <input type="text" name="keyword" id="keyword" value="${article.keyword}" ligerui="width:300"/>
                        <td>（以，隔开）</td>
                    </td>
                </tr>
                <tr>
                    <th><span class="required"></span>置顶时间：</th>
                    <td>
                        <input name="topTimeStr" type="text" value="${article.getTopTimeStr()}" size="10" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
                    </td>
                </tr>
                <tr>
                    <th><span class="required"></span>外   链：</th>
                    <td>
                        <input name="articleUrl" type="text" value="" size="10"  ligerui="width:300"/><td>（填入该项，替换文章链接）</td>
                    </td>
                </tr>
            </table>
        </div>
    </fieldset>

    <!--=============================文章栏目==========================-->
    <fieldset class="field" id="columnAttributeField">
        <legend class="toggleBar">栏目属性</legend>
        <div class="field-bd">
            <table class="tblWrap">
                <tr>
                    <th><span class="required">*</span>主栏目：</th>
                    <td>
                        <input type="text" name="mainColumn" id="mainColumn" ligerui="disabled:true" ltype="text" value="${article.mainColumn}">
                        <input value="ID" type="button" class="l-button sChooBTN showId">
                        <input type="text" class="idValue" ligerui="width:100" name="mainColumnId" id="mainColumnId" value="${article.mainColumnId==0?'':article.mainColumnId}"/>
                    </td>
                    <td><input value="选择栏目" type="button" class="l-button"  onclick="f_select({'targetId':'mainColumn','selectType':'/admin/site/column','callback':'callbackMainColumn','customParam':'&eqStatus=1'})"></td>
                </tr>
                <tr>
                    <th>一稿多投：</th>
                    <td>
                        <input type="text" name="relateColumns" id="relateColumns" ligerui="disabled:true" ltype="text" value="${article.relateColumns}">
                        <input value="ID" type="button" class="l-button sChooBTN showId">
                        <input type="text" class="idValue"  ligerui="width:100"  name="relateColumnIds" id="relateColumnIds" value="${article.relateColumnIds}"/>
                    </td>
                    <td><input value="选择栏目" type="button" class="l-button"  onclick="f_select({'targetId':'relateColumn','selectType':'/admin/site/column','callback':'callbackRelateColumn','customParam':'&eqStatus=1','gridMultiple':'1'})"></td>
                    <td><input value="清空" type="button" class="l-button" onClick="clearText('relateColumns','relateColumnIds')"></td>
                </tr>
                <tr>
                    <th>推送到区块：</th>
                    <td><input type="text" name="regions" id="regions" ltype="text" ligerui="disabled:true" value="${article.regions}">
                        <input value="ID" type="button" class="l-button sChooBTN showId">
                        <input type="text" class="idValue"  ligerui="width:100"  name="regionIds" id="regionIds" value="${article.regionIds}"/>
                    </td>
                    <td><input value="选择区块" type="button" class="l-button" onClick="f_select({'targetId':'regions','selectType':'/admin/site/region','callback':'callbackRegion','customParam':'&eqStatus=1','gridMultiple':'1'})"></td>
                    <td><input value="清空" type="button" class="l-button" onClick="clearText('regions','regionIds')"></td>
                </tr>
            </table>
        </div>
    </fieldset>

    <!--=============================文章组图==========================-->
    <fieldset class="field" id="articlePropertyField">
        <legend class="toggleBar">
            文章缩略图（最多三张）
            <img src="http://static.21cnimg.com/img/icons/silkicons/add.png" title="添加" alt="添加" style="cursor: pointer;"
                 onclick="f_select({'targetId':'firstPicUrl','selectType':'/jsp/admin/resource/picture/uploads.jsp?multi=1&noConfirm=1','dialogWidth':'700','dialogHeight':'500','callback':'setThumbPicUrl'})"/>
        </legend>
        <div class="field-bd">
            <table class="tblWrap">
                <c:if test="${empty articlePictureList}">
                    <tr id="thumbImgBox"></tr>
                </c:if>
                <c:forEach var="articlePicture" items="${articlePictureList}" varStatus="var">
                    <c:if test="${index eq 0 or index % 5 eq 0}">
                        <tr id="thumbImgBox">
                        <th><span class="required"></span></th>
                    </c:if>
                    <c:set var="index" value="${index + 1}"/>
                    <td style="padding-right: 10px;">
                        <img src="${fn:replace(articlePicture.picUrl,'/o/','/s/')}"  width="120" height="90" alt="" title="" />
                        <p>
                            <input type="checkbox" name="thumbPicUrl" value="${articlePicture.picUrl}" <c:if test='${articlePicture.getStatus()==2}'>checked="checked"</c:if>/>
                        </p>
                    </td>
                    <c:if test="${index % 5 eq 0 or var.last}">
                        </tr>
                    </c:if>
                </c:forEach>
            </table>
        </div>
    </fieldset>

    <!--=============================文章摘要==========================-->
    <fieldset class="field" id="leaderetteField">
        <legend class="toggleBar">文章摘要</legend>
        <div class="field-bd">
            <textarea cols="100" rows="4" name="summary" id="summary" class="l-textarea">${article.summary}</textarea>
        </div>
    </fieldset>

    <!--=============================文章正文==========================-->
    <fieldset class="field" id="contentField">
        <legend class="toggleBar">正文内容</legend>
        <div class="field-bd">
            <table class="tblWrap" style="width:100%">
                <tr>
                    <td><textarea id="J_CKEditor" name="content" rows="10" cols="80">${article.content}</textarea></td>
                </tr>
                <tr>
                    <td colspan="2">
                        <table class="tblWrap">
                            <tr>
                                <td style="display:none;"><input type="checkbox" checked="true" name="localPic" id="localPic">远程图片本地化</td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </div>
    </fieldset>
    </div>

    <div class="pnl-ft">
        <c:if test="${empty showType}">
            <input value="提交" type="button" class="l-button" onClick="javascript:submitForm();">
            <input value="取消" type="button" class="l-button" onClick="javascript:top.tab.removeTabItem(top.tab.getSelectedTabItemID());" >
        </c:if>
        <c:if test="${not empty showType}"> <input value="返回" type="button" class="l-button" onClick="javascript:history.back();" ></c:if>
    </div>
</div>
</form:form>
<div style="display:none;"><iframe src="${STATIC_HOST}/jsp/admin/resource/picture/imgFetch.jsp?status=1" id="imgFetchIframeRegion"></iframe></div>
<!-- js代码 -->
<script type="text/javascript" >
    var editor = CKEDITOR.replace( 'J_CKEditor', {});
    var mainform = $("#mainform");
    mainform.ligerForm();                //设置form表单样式
    commonFunction();
    columnAttributeFieldSet();

    function setThumbPicUrl(jsonData) {
        var data= jQuery.parseJSON(jsonData);
        var html = "";
        for(var i=0 ; i< data.length; i++){
            var title = data[i].title;
            var src = data[i].url;
            src = src.replace("/o/","/s/");
            html = html+'<td style="padding: 20px;">'+
                    '<img width="120" height="90" title="'+title+'" alt="'+title+'" src="'+src+'">'+
                    '<p><input type="checkbox" value="'+src+'" name="thumbPicUrl" id="thumbPicUrl"></p>'+
                    '</td>';
        }
        jQuery("#thumbImgBox").append(html);
    }

    function clearText(names,ids){
        if(names!=null){$("#"+names).attr("value","");}
        if(ids!=null){$("#"+ids).attr("value","");}
    }

</script>

<div id="scrolltop">返回顶部</div>
<%@ include file="/jsp/inc/footer.jsp"%>
</body>
</html>